1 00:00:00,670 --> 00:00:01,420 Okay. 2 00:00:01,420 --> 00:00:07,690 In this lecture, let's go ahead and give our players the ability to purchase guns and other items from 3 00:00:07,690 --> 00:00:08,710 our shop. 4 00:00:08,710 --> 00:00:14,380 This means we'll have to listen for when the proximity prompt inside of our shop is triggered, and 5 00:00:14,380 --> 00:00:17,050 then display a shop GUI on the player's screen. 6 00:00:17,050 --> 00:00:22,780 Then the player can press a button to purchase an item, fire to the server that they want to buy something, 7 00:00:22,780 --> 00:00:27,100 and then the server can check if the player has enough money, and then give them the tool and deduct 8 00:00:27,100 --> 00:00:28,870 the money out of their leaderboard. 9 00:00:28,870 --> 00:00:34,480 So the GUI we're going to be displaying on the player's screen is inside of replicated storage in the 10 00:00:34,480 --> 00:00:35,290 shared folder. 11 00:00:35,290 --> 00:00:36,670 And then in the GUI folder. 12 00:00:36,670 --> 00:00:42,400 It's our shop GUI, and I'll parent it into the starter GUI so we can go ahead and take a look at it. 13 00:00:42,400 --> 00:00:44,200 Let me enable UI visibility. 14 00:00:44,200 --> 00:00:51,340 This is our simple shop GUI, and it's simply just a scrolling frame that has different frames inside 15 00:00:51,340 --> 00:00:53,740 of it for the different items we can purchase. 16 00:00:53,740 --> 00:00:59,890 And each of these items has a button inside of it with a name for the item they would like to purchase. 17 00:00:59,890 --> 00:01:03,760 So if they hit this button, then we're going to tell a server we would like to purchase a grenade. 18 00:01:03,760 --> 00:01:08,710 Or for example, if they hit this button, we'll tell the server we want to purchase the pistol and 19 00:01:08,710 --> 00:01:09,400 so on. 20 00:01:09,400 --> 00:01:13,780 So the server's job is going to listen for when the player clicks these buttons. 21 00:01:13,780 --> 00:01:17,200 And then we're going to check to see if the player has enough money. 22 00:01:17,200 --> 00:01:19,540 And if they do we can give them the item. 23 00:01:19,540 --> 00:01:25,120 So let me go ahead and move this back inside of the GUI folder. 24 00:01:25,540 --> 00:01:27,730 And then let me disable UI visibility. 25 00:01:27,730 --> 00:01:31,450 And let's go ahead and create a new script inside of server script service. 26 00:01:31,450 --> 00:01:35,200 And this can be the script responsible for handling our shop. 27 00:01:35,200 --> 00:01:36,880 So we'll call it the shop handler. 28 00:01:38,390 --> 00:01:41,060 We'll be using the same comet template as before. 29 00:01:42,000 --> 00:01:50,070 And what we want to do is we want to enable this proximity prompt that is in our shop only when the 30 00:01:50,070 --> 00:01:54,660 game is set, either in the starting intermission or the intermission between waves. 31 00:01:54,660 --> 00:02:00,360 So when a wave starts or the game is currently in cleanup mode, we want to basically close down the 32 00:02:00,360 --> 00:02:00,840 shop. 33 00:02:00,840 --> 00:02:06,420 We want to hide this guy up here and disable the proximity prompt so players can't purchase stuff while 34 00:02:06,420 --> 00:02:07,830 a wave is going on. 35 00:02:08,320 --> 00:02:13,960 So what we can go ahead and do is we can listen for when the workspace has an attribute changed. 36 00:02:13,960 --> 00:02:17,080 And that attribute we're going to get attribute change signal. 37 00:02:17,080 --> 00:02:20,260 And that is going to be the game state attribute. 38 00:02:20,260 --> 00:02:22,750 And then we can connect a function to this event. 39 00:02:22,900 --> 00:02:28,630 And then we can go ahead and get the current game state which is equal to workspace get attribute game 40 00:02:28,630 --> 00:02:29,230 state. 41 00:02:29,950 --> 00:02:34,960 And then we can check to see what the current game state is, and if it's in the intermission or start 42 00:02:34,960 --> 00:02:36,640 intermission, we'll enable the shop. 43 00:02:36,640 --> 00:02:38,470 Otherwise we'll disable the shop. 44 00:02:38,470 --> 00:02:42,880 So let's go ahead and get the game state enum and Replicated Storage. 45 00:02:42,880 --> 00:02:45,220 So we'll grab replicated storage. 46 00:02:49,330 --> 00:02:56,920 And then we can go ahead and get our game state enum and we'll require from replicated storage dot modules, 47 00:02:56,920 --> 00:02:58,960 dot enums dot game state enum. 48 00:02:59,230 --> 00:03:07,150 So if the workspace is current, game state is equal to the game state enum of intermission, or the 49 00:03:07,150 --> 00:03:15,280 game state is equal to the game state enum of start intermission, then we're okay to go ahead and enable 50 00:03:15,280 --> 00:03:19,030 that proximity prompt and the billboard guy over our shop. 51 00:03:19,030 --> 00:03:22,090 So let's go ahead and make a variable for those things. 52 00:03:22,090 --> 00:03:24,130 We first want to refer to our shop. 53 00:03:24,130 --> 00:03:27,070 And that's in the workspace in the map folder. 54 00:03:27,070 --> 00:03:30,250 And it's simply called our I believe Weapon shop. 55 00:03:30,250 --> 00:03:31,030 There we go. 56 00:03:31,210 --> 00:03:35,440 We can go ahead and grab the prompt inside of our weapon shop, which is inside of our shop. 57 00:03:35,860 --> 00:03:39,520 We're going to get the proximity part and then get the prompt that's inside of there. 58 00:03:39,520 --> 00:03:41,680 And then we can also grab the billboard guy. 59 00:03:41,680 --> 00:03:46,540 We'll just call it guy and that's equal to shop and we'll grab our billboard guy. 60 00:03:46,540 --> 00:03:49,000 So in the game state is in the intermission. 61 00:03:49,000 --> 00:03:52,480 Then we're going to make sure that our prompt is enabled. 62 00:03:52,480 --> 00:03:53,590 So we'll set that equal to true. 63 00:03:53,590 --> 00:03:56,080 And we'll also make sure our guy is enabled. 64 00:03:56,140 --> 00:04:01,960 Otherwise if the game state is not in the intermission, then we'll make sure that our prompt is disabled 65 00:04:01,960 --> 00:04:04,570 and that our guy is also disabled. 66 00:04:04,900 --> 00:04:09,580 Then from this point, we could go ahead and listen to when our prompt is triggered by a player. 67 00:04:09,580 --> 00:04:12,280 So we'll connect a function and get that player. 68 00:04:12,640 --> 00:04:18,400 And what we want to go ahead and do is we want to clone the guy that is in replicated storage and give 69 00:04:18,400 --> 00:04:19,930 it to our player. 70 00:04:19,930 --> 00:04:23,950 So the first thing we need to do is just in case. 71 00:04:23,950 --> 00:04:28,030 For some reason, the game state is not in the intermission game state. 72 00:04:28,030 --> 00:04:30,010 We can check inside of here as well. 73 00:04:30,010 --> 00:04:34,510 So I'm going to copy this and paste this here. 74 00:04:35,060 --> 00:04:41,600 So if the game state is not equal to the regular intermission and the game state is not equal to the 75 00:04:41,600 --> 00:04:44,180 start intermission, then we don't want to give them a GUI. 76 00:04:44,210 --> 00:04:45,890 So we're just going to return. 77 00:04:46,100 --> 00:04:51,260 Otherwise we got to check if the player already has this guy displayed on their screen. 78 00:04:51,260 --> 00:04:59,330 So if this player and in their player GUI folder we find first child which is the shop GUI, then that 79 00:04:59,330 --> 00:05:06,290 means we shouldn't give the player a new guy so we could either return, or another thing we could do 80 00:05:06,290 --> 00:05:11,750 is we could refer to that player's GUI and then just destroy it so it's not on their screen anymore. 81 00:05:11,750 --> 00:05:13,760 So shop GUI destroy. 82 00:05:14,870 --> 00:05:20,000 And then we could return, or we could just actually give and display them a new one. 83 00:05:20,000 --> 00:05:23,510 But in this case, we're just going to create a new clone of our shop guy. 84 00:05:23,510 --> 00:05:25,310 So let's go ahead and make a variable for that. 85 00:05:25,640 --> 00:05:26,840 We'll call it our shop guy. 86 00:05:26,840 --> 00:05:31,490 And that's in replicated storage dot shared dot GIS dot shop guy. 87 00:05:31,670 --> 00:05:38,930 And then we can go ahead and clone our shop guy and then set the parent of that clone equal to our players 88 00:05:38,930 --> 00:05:39,890 player guy folder. 89 00:05:39,890 --> 00:05:41,720 So it displays on their screen. 90 00:05:41,900 --> 00:05:46,040 And then this is where we would have a local script inside of that shop guy. 91 00:05:46,040 --> 00:05:50,660 And then once we parent it to the players player guy folder, that local script will execute on the 92 00:05:50,660 --> 00:05:54,800 client side, allowing the player to interact with the buttons in the GUI. 93 00:05:55,670 --> 00:06:01,160 So actually let's go ahead and go into replicated storage and let's create a new local script inside 94 00:06:01,160 --> 00:06:02,480 of our shop GUI. 95 00:06:02,480 --> 00:06:05,240 And this can be our shop GUI handler. 96 00:06:05,950 --> 00:06:08,200 We'll use the same common template. 97 00:06:12,200 --> 00:06:16,550 And inside of here we can go ahead and make a variable to refer to the GUI itself, which is script 98 00:06:16,550 --> 00:06:17,390 dot parent. 99 00:06:17,540 --> 00:06:22,280 And then we want to go ahead and refer to the frame holding all of the stuff in the GUI. 100 00:06:22,280 --> 00:06:24,740 So that's equal to g dot background frame. 101 00:06:24,740 --> 00:06:28,550 And then we want to go ahead and also grab the close button of our shop. 102 00:06:28,550 --> 00:06:32,570 So if the player presses the close button we'll remove it from the player. 103 00:06:32,570 --> 00:06:35,330 So that'll be equal to frame dot close button. 104 00:06:36,390 --> 00:06:42,060 And then we'll also get the frame that's holding all of the different items in our shop. 105 00:06:42,060 --> 00:06:46,920 So that's the shop frame and that's going to be frame dot shop frame. 106 00:06:47,910 --> 00:06:52,950 Now in order to communicate to the server when we want to buy something, we have an event inside of 107 00:06:52,950 --> 00:06:59,850 the remotes folder inside of GUI, which is our buy item event, so we can go ahead and grab replicated 108 00:06:59,850 --> 00:07:00,780 storage. 109 00:07:05,710 --> 00:07:07,900 And then we'll make a reference to that event. 110 00:07:07,900 --> 00:07:14,380 We'll just call it our BI event that's equal to replicated storage, dot remotes, dot gui dot buy item. 111 00:07:15,210 --> 00:07:19,230 Then what we can go ahead and do is to make this really simple. 112 00:07:19,230 --> 00:07:25,020 Instead of having to refer to every single button that is inside of our shop frame, we can instead 113 00:07:25,020 --> 00:07:30,210 loop through all of the descendants of our shop frame, check to see if it's one of these frames, and 114 00:07:30,210 --> 00:07:35,550 then grab the button in there, and then listen for when that button is clicked and fire to the server 115 00:07:35,550 --> 00:07:40,860 the name of this button so the server knows which item the player wants to purchase. 116 00:07:40,860 --> 00:07:45,540 So we could create a dedicated function to listen for when a particular button is clicked. 117 00:07:45,540 --> 00:07:50,040 We'll call it on button clicked, and we'll get passed to this function. 118 00:07:50,040 --> 00:07:54,180 The name of the item they want to purchase, which should be the name of the button. 119 00:07:54,180 --> 00:07:57,180 And then we could use our buy event and fire to the server. 120 00:07:57,180 --> 00:08:03,630 Hey, we want to buy this particular item, so then we can loop through all of the buttons inside of 121 00:08:03,630 --> 00:08:05,310 our shop frame get. 122 00:08:05,970 --> 00:08:07,200 Descendants. 123 00:08:07,590 --> 00:08:13,410 And what we want to do is we want to make sure that this element that we're looping through is actually 124 00:08:13,410 --> 00:08:14,100 a button. 125 00:08:14,100 --> 00:08:20,100 So if this particular element is not a button, so is a text button. 126 00:08:20,400 --> 00:08:26,400 If it is not a text button, then we're just going to continue to the next iteration of this loop. 127 00:08:26,400 --> 00:08:30,240 Otherwise we can go ahead and listen for when this button is activated. 128 00:08:30,390 --> 00:08:32,130 And then we'll connect a function. 129 00:08:32,130 --> 00:08:38,580 And this is where we would go ahead and call our on button clicked, and then pass the name of our button. 130 00:08:39,540 --> 00:08:44,220 And then the other thing we want to go ahead and listen to is when our close button is activated. 131 00:08:44,220 --> 00:08:49,710 And then we can connect a function and simply just disable the GUI. 132 00:08:49,950 --> 00:08:55,440 And since we're doing it this way, that means the GUI is still going to be inside of our player GUI 133 00:08:55,470 --> 00:08:56,250 folder. 134 00:08:56,250 --> 00:09:02,970 And that means the next time a player goes and they trigger the proximity prompt to reopen it on their 135 00:09:02,970 --> 00:09:07,860 screen, the server is simply going to delete their previous one and give them a new one. 136 00:09:09,180 --> 00:09:12,780 And I believe that's all we need to do for our shop guy. 137 00:09:12,810 --> 00:09:17,910 So back inside of our shop handler, we need to go ahead and listen to that by event and check to see 138 00:09:17,910 --> 00:09:20,880 if the player has enough money to purchase a particular item. 139 00:09:21,630 --> 00:09:24,990 So let's go ahead and make a variable for our by event. 140 00:09:24,990 --> 00:09:29,760 And that's in replicated storage dot remotes dot guy dot buy item. 141 00:09:31,500 --> 00:09:36,120 And then we can go ahead and listen to when our by event is fired. 142 00:09:36,120 --> 00:09:38,700 So on server event will connect a function. 143 00:09:38,700 --> 00:09:42,780 We'll get the player and then the name of the item they wish to purchase. 144 00:09:43,760 --> 00:09:48,440 And then what we could go out and do is create a table containing the names of all of the different 145 00:09:48,440 --> 00:09:51,230 items that are possible to purchase. 146 00:09:51,230 --> 00:09:55,280 So I'll call this my tools table. 147 00:09:55,280 --> 00:10:00,020 And inside of here we'll have a key which represents the name of a particular item. 148 00:10:00,020 --> 00:10:05,750 And then we could set the price and then the tool for that particular item. 149 00:10:05,750 --> 00:10:12,170 So for example if one of the buttons the player presses is the pistol button, then the client is going 150 00:10:12,170 --> 00:10:14,450 to send to the server the name of pistol. 151 00:10:14,450 --> 00:10:16,550 So we'll make that one of the keys in our table. 152 00:10:16,550 --> 00:10:17,600 So pistol. 153 00:10:17,690 --> 00:10:19,580 And we'll set that equal to a table. 154 00:10:19,580 --> 00:10:26,180 And inside of here we can define the price of that particular item as well as the tool associated with 155 00:10:26,180 --> 00:10:27,170 this name. 156 00:10:27,170 --> 00:10:31,370 So for the pistol inside of our GUI we set that to the price of $60. 157 00:10:31,370 --> 00:10:35,960 And then the associated tool with that is stored in server storage. 158 00:10:35,960 --> 00:10:42,380 So let's go ahead and make a reference to server storage game git service server storage. 159 00:10:42,380 --> 00:10:45,590 And the tool is in server storage tools. 160 00:10:45,590 --> 00:10:47,450 And we'll get the pistol. 161 00:10:48,290 --> 00:10:51,350 Another item that the player can purchase is the SMG. 162 00:10:51,350 --> 00:10:52,970 And the button is called SMG. 163 00:10:52,970 --> 00:10:55,310 And we'll set that equal to another table. 164 00:10:55,310 --> 00:10:57,560 The price for that is set at 100. 165 00:10:57,560 --> 00:11:02,720 And then the associated tool is equal to the server storage dot tools dot SMG. 166 00:11:02,720 --> 00:11:06,890 And then we can just continue doing this for every single purchasable item in our game. 167 00:11:06,890 --> 00:11:11,630 For example they can purchase a rifle and the rifle costs 200. 168 00:11:11,990 --> 00:11:15,710 And then we'll refer to our rifle, which I believe it's called assault rifle. 169 00:11:15,710 --> 00:11:16,370 There we go. 170 00:11:18,820 --> 00:11:21,790 Another item we can purchase is a regular shotgun. 171 00:11:21,820 --> 00:11:25,630 The price we set for that one is also set at 200. 172 00:11:25,630 --> 00:11:29,800 And that's going to be equal to our shotgun. 173 00:11:29,800 --> 00:11:32,890 And we'll do the buckshot shotgun. 174 00:11:34,330 --> 00:11:37,360 The next item they can purchase would be the shotgun. 175 00:11:37,360 --> 00:11:40,150 And the button is called shotgun slugs. 176 00:11:40,150 --> 00:11:42,940 And we set the price of that one equal to 250. 177 00:11:42,940 --> 00:11:47,260 And that's going to be our shotgun of slugs. 178 00:11:47,740 --> 00:11:53,770 The next one would be the semi-auto shotgun I believe that's how we named it. 179 00:11:53,770 --> 00:11:58,420 So if we go ahead and take a look at the button for that one. 180 00:11:58,420 --> 00:11:58,660 Yep. 181 00:11:58,660 --> 00:12:00,880 It says semi-auto shotgun. 182 00:12:01,060 --> 00:12:05,440 So we'll make sure that this key matches the name of the button. 183 00:12:05,440 --> 00:12:10,060 And then we'll refer to that inside of our tools folder that is the semi-auto shotgun. 184 00:12:10,630 --> 00:12:14,950 And then players could also purchase other things such as a mic kit. 185 00:12:15,250 --> 00:12:17,620 So we'll call this one med kit. 186 00:12:17,650 --> 00:12:24,070 The price of a med kit we set to $30 and the tool is our med kit. 187 00:12:24,610 --> 00:12:29,200 And then last but not least, in the future we're going to be scripting our grenade. 188 00:12:29,200 --> 00:12:34,630 But just for demonstration sake, we're going to also add our grenade into our table. 189 00:12:34,630 --> 00:12:35,620 Forgot a comma there. 190 00:12:35,620 --> 00:12:36,790 And we put that there. 191 00:12:37,630 --> 00:12:41,440 And the price for our grenade is equal to $40. 192 00:12:41,440 --> 00:12:45,490 And the tool is going to be in service storage dot tools dot grenade. 193 00:12:46,450 --> 00:12:51,040 So now what we can go ahead and do is when this event is fired, we first want to make sure that the 194 00:12:51,040 --> 00:12:57,070 game is in a state where the player can purchase an item because an exploiter could fire this event 195 00:12:57,070 --> 00:13:00,340 while the players are in the middle of a wave. 196 00:13:00,340 --> 00:13:05,530 And we don't want to give that player an item unless the game is in the intermission state. 197 00:13:05,530 --> 00:13:09,130 So we're basically just going to copy this here and paste that there. 198 00:13:09,130 --> 00:13:11,920 So if it's not in intermission, we're going to return. 199 00:13:12,160 --> 00:13:17,920 Otherwise we also need to verify that the name of the item they passed here is actually a possible item 200 00:13:17,920 --> 00:13:20,260 to purchase within our tools table. 201 00:13:20,590 --> 00:13:28,330 So if we do not find this particular tool or this name of the item in our tools table, then we're also 202 00:13:28,330 --> 00:13:29,740 just going to return. 203 00:13:30,640 --> 00:13:35,920 Another thing we need to check is if the player has enough money to purchase this particular tool. 204 00:13:35,920 --> 00:13:39,880 So we're going to calculate what the after balance would be for our player. 205 00:13:39,880 --> 00:13:45,130 When we subtract the price of this tool to the current amount of money the player has. 206 00:13:45,130 --> 00:13:47,230 So that's going to be equal to player. 207 00:13:47,260 --> 00:13:52,660 Get their leaderstats folder, get the money, and then get the value of that and subtract it by this 208 00:13:52,660 --> 00:13:54,070 particular tools. 209 00:13:54,070 --> 00:13:57,790 And then we'll pass the name of the item and we'll get the price of that tool. 210 00:13:58,210 --> 00:14:01,600 And then we can check if this after balance is less than zero. 211 00:14:01,600 --> 00:14:03,760 So they would have a negative balance. 212 00:14:03,760 --> 00:14:07,120 And that clearly means the player did not have enough money to purchase this item. 213 00:14:07,120 --> 00:14:08,890 So we're also going to return. 214 00:14:09,670 --> 00:14:16,690 Another thing we need to check for is if this player already has this tool in their inventory, because 215 00:14:16,690 --> 00:14:22,330 we don't want players to purchase a duplicate guns, the only things that we would allow them to purchase 216 00:14:22,330 --> 00:14:25,870 as duplicates would be the one use Medkits. 217 00:14:25,870 --> 00:14:30,040 So if inside of our player's backpack we find first child. 218 00:14:30,740 --> 00:14:32,990 And then we need to get the name of the tool. 219 00:14:32,990 --> 00:14:34,400 So that's going to be in tools. 220 00:14:34,400 --> 00:14:38,900 We'll pass the name of item, get that tool and then get the name of the tool. 221 00:14:38,900 --> 00:14:44,120 If we find this tool in their backpack, or let's say we find it on their player's character. 222 00:14:44,120 --> 00:14:48,980 So or player dot character find first child this. 223 00:14:48,980 --> 00:14:54,710 And then we also need to make sure that the name of this item is in our med kit, because we want our 224 00:14:54,710 --> 00:14:56,990 player to be able to purchase multiple med kits. 225 00:14:56,990 --> 00:14:59,930 So then we'll put an end statement here. 226 00:15:01,960 --> 00:15:02,470 So. 227 00:15:02,470 --> 00:15:07,270 And let's check to see if the tools pass. 228 00:15:07,270 --> 00:15:08,560 Name of item. 229 00:15:10,050 --> 00:15:11,640 Get the tool and get the name. 230 00:15:11,640 --> 00:15:17,340 If it's not equal to med kit, then we're going to return. 231 00:15:19,110 --> 00:15:22,590 So let me go ahead and get rid of that duplicate then statement. 232 00:15:22,590 --> 00:15:23,310 So. 233 00:15:23,910 --> 00:15:25,350 This looks a little bit more concise. 234 00:15:25,350 --> 00:15:26,730 Let me shift this down. 235 00:15:26,730 --> 00:15:32,880 So if the player has this tool in their backpack or they have it equipped on their character, and the 236 00:15:32,880 --> 00:15:37,380 name of this tool is not equal to our med kit, then we're going to ignore this player because we do 237 00:15:37,380 --> 00:15:39,600 not want to give them duplicate tools. 238 00:15:39,810 --> 00:15:45,990 Otherwise we can go ahead and update the value inside of the player's leader stats dot money int value 239 00:15:45,990 --> 00:15:48,600 and set that value equal to our after balance. 240 00:15:48,900 --> 00:15:53,580 And then we can go ahead and make a clone of the tool that they want to purchase. 241 00:15:53,580 --> 00:15:55,590 So we'll clone that. 242 00:15:55,710 --> 00:16:00,600 And then we can go ahead and set the parent of that clone equal to the player's backpack. 243 00:16:01,290 --> 00:16:07,440 So now we should have scripted everything we need to allow players to purchase items from our shop. 244 00:16:07,740 --> 00:16:14,130 So let's go ahead and make sure inside of our game handler script that we're setting the game state 245 00:16:14,130 --> 00:16:15,330 to an intermission. 246 00:16:15,330 --> 00:16:21,060 So we're setting it to the start intermission, which means we should be able to display all of the 247 00:16:21,060 --> 00:16:22,500 items in our shop. 248 00:16:22,500 --> 00:16:28,950 And actually, what we should do down here in this main section is we should check the game state of 249 00:16:28,950 --> 00:16:30,180 the workspace. 250 00:16:30,450 --> 00:16:34,680 So we'll get the game state if the game state is equal to. 251 00:16:35,520 --> 00:16:39,570 The intermission or it's equal to the start intermission. 252 00:16:39,570 --> 00:16:44,130 Then we'll make sure to enable the prompt and the GUI for the shop. 253 00:16:44,310 --> 00:16:45,990 So we'll paste that right there. 254 00:16:46,740 --> 00:16:50,550 So now we should be able to purchase items from our shop. 255 00:16:50,550 --> 00:16:52,410 Let's go ahead and playtest and find out. 256 00:16:53,500 --> 00:16:55,750 Go and play our game here. 257 00:16:57,400 --> 00:17:01,450 And then we can go ahead and play our game and spawn into the map. 258 00:17:01,450 --> 00:17:04,420 And let's go over and see if that prompt is enabled. 259 00:17:04,810 --> 00:17:06,490 So as you can see it says open shop. 260 00:17:06,490 --> 00:17:12,220 If I trigger the prompt, as you can see, the server cloned that guy into my player guy folder and 261 00:17:12,220 --> 00:17:13,780 now it's displayed on my screen. 262 00:17:14,470 --> 00:17:19,210 And since I don't have enough money to purchase anything, if I click these buttons, nothing should 263 00:17:19,210 --> 00:17:19,540 happen. 264 00:17:19,540 --> 00:17:20,530 So if I click. 265 00:17:21,450 --> 00:17:24,780 As we expect nothing would happen because we don't have any money. 266 00:17:24,810 --> 00:17:30,270 Now, if I go to the server and I give my player some money, so let me go ahead and give me a bunch 267 00:17:30,270 --> 00:17:30,900 of money. 268 00:17:31,800 --> 00:17:32,820 Do something like that. 269 00:17:32,820 --> 00:17:33,960 Go back to the client. 270 00:17:33,990 --> 00:17:35,700 Now I have $1 million. 271 00:17:35,700 --> 00:17:38,190 Let's see if I can actually purchase something like a pistol. 272 00:17:38,190 --> 00:17:39,270 So if I click this. 273 00:17:39,950 --> 00:17:40,670 There we go. 274 00:17:40,670 --> 00:17:46,190 I got the pistol added to my inventory, and then it deducted that amount of money from my money int 275 00:17:46,190 --> 00:17:46,820 value. 276 00:17:46,850 --> 00:17:48,860 I can also purchase a rifle. 277 00:17:49,950 --> 00:17:51,840 Actually, it's not letting me purchase a rifle. 278 00:17:51,840 --> 00:17:52,530 Very interesting. 279 00:17:52,530 --> 00:17:53,460 How about an SMG? 280 00:17:53,880 --> 00:17:55,470 I can purchase an SMG. 281 00:17:55,620 --> 00:17:58,500 I can purchase a shotgun, a semi-auto shotgun. 282 00:17:58,500 --> 00:18:04,920 I can purchase slugs, but it does look like I am not able to purchase a rifle, which could mean that 283 00:18:04,920 --> 00:18:07,410 we got the name messed up a little bit. 284 00:18:08,400 --> 00:18:13,050 So let's go ahead and confirm that the name of our button matches the server. 285 00:18:13,050 --> 00:18:15,210 So the name of our button is rifle. 286 00:18:15,210 --> 00:18:20,220 And then if we go back to our shop handler let's make sure that actually matches. 287 00:18:20,960 --> 00:18:24,140 So yes, it's also spelt out as a rifle. 288 00:18:24,140 --> 00:18:30,710 Right here we have the price set and then we should be referring to the assault rifle. 289 00:18:31,460 --> 00:18:33,410 And it should be allowing us to purchase it. 290 00:18:33,410 --> 00:18:36,380 I wonder why it didn't let us purchase the assault rifle. 291 00:18:37,050 --> 00:18:40,410 That's why I already had the assault rifle inside of my starter pack. 292 00:18:40,410 --> 00:18:42,270 So let me actually go ahead and delete it. 293 00:18:42,800 --> 00:18:44,570 And then playtest my game. 294 00:18:44,570 --> 00:18:47,870 I guess I didn't notice that I already had my assault rifle on me. 295 00:18:48,620 --> 00:18:50,330 So let's go ahead and try that again. 296 00:18:51,550 --> 00:18:52,750 If I open my shop. 297 00:18:52,750 --> 00:18:54,760 As you can see, I can't purchase anything. 298 00:18:54,760 --> 00:18:57,250 But if I give my player some money. 299 00:18:58,520 --> 00:19:01,730 I'll just get my player a whole bunch of money and we'll go back. 300 00:19:02,370 --> 00:19:04,710 And then if I were to purchase the rifle. 301 00:19:04,710 --> 00:19:05,160 There we go. 302 00:19:05,160 --> 00:19:07,020 I get the rifle, I get the pistol. 303 00:19:07,020 --> 00:19:11,160 And then if I try to buy this item again, as you can see, it's not giving me anything because I already 304 00:19:11,160 --> 00:19:15,900 have a rifle in my inventory, but I can buy all the other stuff as well as the grenade and the med 305 00:19:15,900 --> 00:19:16,320 kit. 306 00:19:16,320 --> 00:19:19,380 And then we shouldn't be limited on how many med kits we can purchase. 307 00:19:19,380 --> 00:19:20,730 So if I keep clicking this. 308 00:19:21,730 --> 00:19:27,040 As you can see, the server is continuing to give me med kits because we've set no limit on how many 309 00:19:27,040 --> 00:19:28,570 med kits a player can buy. 310 00:19:30,190 --> 00:19:32,680 Okay, we've got our shop all set up. 311 00:19:32,680 --> 00:19:35,320 You're doing a great job so far with this project. 312 00:19:35,320 --> 00:19:38,350 Keep up the good work and I'll see you in the next lecture.